package cn.cdu.medical.controller;

import cn.cdu.basics.baseVo.Result;
import cn.cdu.basics.utils.ResultUtil;
import cn.cdu.medical.dto.HealthVisualizationDTO;
import cn.cdu.medical.dto.DiseaseDTO;
import cn.cdu.medical.dto.VisitDTO;
import cn.cdu.medical.service.HealthVisualizationService;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/zwz/health")
@Tag(name = "健康可视化接口")
@CrossOrigin(origins = "*", maxAge = 3600)
public class HealthVisualizationController {
    @Autowired
    private HealthVisualizationService healthVisualizationService;

    @GetMapping("/visualization/{userId}")
    @Operation(summary = "获取患者健康可视化数据")
    public Result<HealthVisualizationDTO> getHealthVisualization(@PathVariable String userId) {
        HealthVisualizationDTO data = healthVisualizationService.getHealthVisualization(userId);
        return new ResultUtil<HealthVisualizationDTO>().setData(data);
    }

    @GetMapping("/diseases/{userId}")
    @Operation(summary = "获取患者疾病分布数据")
    public Result<List<DiseaseDTO>> getDiseaseDistribution(@PathVariable String userId) {
        List<DiseaseDTO> data = healthVisualizationService.getDiseaseDistribution(userId);
        return new ResultUtil<List<DiseaseDTO>>().setData(data);
    }

    @GetMapping("/visits/{userId}")
    @Operation(summary = "获取患者就诊记录")
    public Result<List<VisitDTO>> getVisitRecords(@PathVariable String userId) {
        List<VisitDTO> data = healthVisualizationService.getVisitRecords(userId);
        return new ResultUtil<List<VisitDTO>>().setData(data);
    }
} 